public class Test1 {
    public static void main(String[] args) {

    }
    public int findMin(int[] nums) {
        int left = 0 ;
        int right = nums.length - 1 ;
        int target = nums[right];
        while(left < right){
            int mid = left + (right - left)/2 ;
            if(nums[mid] <= target){
                right = mid ;
            }else{
                left = mid +1 ;
            }
        }
        return nums[left];
    }
    public int takeAttendance(int[] records) {
        int left = 0 ;
        int right = records.length -1 ;

        while(left < right){
            int mid = left + (right - left) /2 ;
            if(records[mid] > mid){
                right = mid ;
            }else{
                left = mid + 1;
            }
        }
        if(records[left] == left){
            return left + 1;
        }
        return left ;
    }
}
